package com.hmall.search.web;

import com.hmall.common.dto.PageDTO;
import com.hmall.item.service.impl.ItemService;
import com.hmall.search.pojo.ItemDoc;
import com.hmall.search.pojo.RequestParams;
import com.hmall.search.service.IsearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    private IsearchService searchService;
    // 搜索自动补全
    @GetMapping("/suggestion")
    public List<String> suggestion(String key){
        return searchService.suggestion(key);
    }

    //过滤项聚合功能
    @PostMapping("/filters")
    public Map<String,List<String>> filters(@RequestBody RequestParams requestParams){
        return searchService.filters(requestParams);
    }

    //商品条件查询
    @PostMapping("/list")
    public PageDTO<ItemDoc> itemList(@RequestBody RequestParams requestParams){
        return searchService.itemList(requestParams);
    }
}
